home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / atarigen.h < prev    next >
C/C++ Source or Header  |  2000-05-04  |  26KB  |  633 lines

  1. /***************************************************************************
  2.  
  3.   atarigen.h
  4.  
  5.   General functions for mid-to-late 80's Atari raster games.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10.  
  11. #ifndef __MACHINE_ATARIGEN__
  12. #define __MACHINE_ATARIGEN__
  13.  
  14.  
  15. #define ATARI_CLOCK_14MHz    14318180
  16. #define ATARI_CLOCK_20MHz    20000000
  17. #define ATARI_CLOCK_32MHz    32000000
  18. #define ATARI_CLOCK_50MHz    50000000
  19.  
  20.  
  21.  
  22. /*--------------------------------------------------------------------------
  23.  
  24.     Atari generic interrupt model (required)
  25.  
  26.         atarigen_scanline_int_state - state of the scanline interrupt line
  27.         atarigen_sound_int_state - state of the sound interrupt line
  28.         atarigen_video_int_state - state of the video interrupt line
  29.  
  30.         atarigen_int_callback - called when the interrupt state changes
  31.  
  32.         atarigen_interrupt_reset - resets & initializes the interrupt state
  33.         atarigen_update_interrupts - forces the interrupts to be reevaluted
  34.  
  35.         atarigen_scanline_int_set - scanline interrupt initialization
  36.         atarigen_sound_int_gen - scanline interrupt generator
  37.         atarigen_scanline_int_ack_w - scanline interrupt acknowledgement
  38.  
  39.         atarigen_sound_int_gen - sound interrupt generator
  40.         atarigen_sound_int_ack_w - sound interrupt acknowledgement
  41.  
  42.         atarigen_video_int_gen - video interrupt generator
  43.         atarigen_video_int_ack_w - video interrupt acknowledgement
  44.  
  45. --------------------------------------------------------------------------*/
  46. extern int atarigen_scanline_int_state;
  47. extern int atarigen_sound_int_state;
  48. extern int atarigen_video_int_state;
  49.  
  50. typedef void (*atarigen_int_callback)(void);
  51.  
  52. void atarigen_interrupt_reset(atarigen_int_callback update_int);
  53. void atarigen_update_interrupts(void);
  54.  
  55. void atarigen_scanline_int_set(int scanline);
  56. int atarigen_scanline_int_gen(void);
  57. WRITE_HANDLER( atarigen_scanline_int_ack_w );
  58.  
  59. int atarigen_sound_int_gen(void);
  60. WRITE_HANDLER( atarigen_sound_int_ack_w );
  61.  
  62. int atarigen_video_int_gen(void);
  63. WRITE_HANDLER( atarigen_video_int_ack_w );
  64.  
  65.  
  66. /*--------------------------------------------------------------------------
  67.  
  68.     EEPROM I/O (optional)
  69.  
  70.         atarigen_eeprom_default - pointer to compressed default data
  71.         atarigen_eeprom - pointer to base of EEPROM memory
  72.         atarigen_eeprom_size - size of EEPROM memory
  73.  
  74.         atarigen_eeprom_reset - resets the EEPROM system
  75.  
  76.         atarigen_eeprom_enable_w - write handler to enable EEPROM access
  77.         atarigen_eeprom_w - write handler for EEPROM data
  78.         atarigen_eeprom_r - read handler for EEPROM data (low byte)
  79.         atarigen_eeprom_upper_r - read handler for EEPROM data (high byte)
  80.  
  81.         atarigen_nvram_handler - load/save EEPROM data
  82.  
  83. --------------------------------------------------------------------------*/
  84. extern const UINT16 *atarigen_eeprom_default;
  85. extern UINT8 *atarigen_eeprom;
  86. extern size_t atarigen_eeprom_size;
  87.  
  88. void atarigen_eeprom_reset(void);
  89.  
  90. WRITE_HANDLER( atarigen_eeprom_enable_w );
  91. WRITE_HANDLER( atarigen_eeprom_w );
  92. READ_HANDLER( atarigen_eeprom_r );
  93. READ_HANDLER( atarigen_eeprom_upper_r );
  94.  
  95. void atarigen_nvram_handler(void *file,int read_or_write);
  96. void atarigen_hisave(void);
  97.  
  98.  
  99. /*--------------------------------------------------------------------------
  100.  
  101.     Slapstic I/O (optional)
  102.  
  103.         atarigen_slapstic_init - select and initialize the slapstic handlers
  104.         atarigen_slapstic_reset - resets the slapstic state
  105.  
  106.         atarigen_slapstic_w - write handler for slapstic data
  107.         atarigen_slapstic_r - read handler for slapstic data
  108.  
  109.         slapstic_init - low-level init routine
  110.         slapstic_reset - low-level reset routine
  111.         slapstic_bank - low-level routine to return the current bank
  112.         slapstic_tweak - low-level tweak routine
  113.  
  114. --------------------------------------------------------------------------*/
  115. void atarigen_slapstic_init(int cpunum, int base, int chipnum);
  116. void atarigen_slapstic_reset(void);
  117.  
  118. WRITE_HANDLER( atarigen_slapstic_w );
  119. READ_HANDLER( atarigen_slapstic_r );
  120.  
  121. void slapstic_init(int chip);
  122. void slapstic_reset(void);
  123. int slapstic_bank(void);
  124. int slapstic_tweak(offs_t offset);
  125.  
  126.  
  127.  
  128. /***********************************************************************************************/
  129. /***********************************************************************************************/
  130. /***********************************************************************************************/
  131. /***********************************************************************************************/
  132. /***********************************************************************************************/
  133.  
  134.  
  135.  
  136. /*--------------------------------------------------------------------------
  137.  
  138.     Sound I/O
  139.  
  140.         atarigen_sound_io_reset - reset the sound I/O system
  141.  
  142.         atarigen_6502_irq_gen - standard 6502 IRQ interrupt generator
  143.         atarigen_6502_irq_ack_r - standard 6502 IRQ interrupt acknowledgement
  144.         atarigen_6502_irq_ack_w - standard 6502 IRQ interrupt acknowledgement
  145.  
  146.         atarigen_ym2151_irq_gen - YM2151 sound IRQ generator
  147.  
  148.         atarigen_sound_w - Main CPU -> sound CPU data write (low byte)
  149.         atarigen_sound_r - Sound CPU -> main CPU data read (low byte)
  150.         atarigen_sound_upper_w - Main CPU -> sound CPU data write (high byte)
  151.         atarigen_sound_upper_r - Sound CPU -> main CPU data read (high byte)
  152.  
  153.         atarigen_sound_reset_w - 6502 CPU reset
  154.         atarigen_6502_sound_w - Sound CPU -> main CPU data write
  155.         atarigen_6502_sound_r - Main CPU -> sound CPU data read
  156.  
  157. --------------------------------------------------------------------------*/
  158. extern int atarigen_cpu_to_sound_ready;
  159. extern int atarigen_sound_to_cpu_ready;
  160.  
  161. void atarigen_sound_io_reset(int cpu_num);
  162.  
  163. int atarigen_6502_irq_gen(void);
  164. READ_HANDLER( atarigen_6502_irq_ack_r );
  165. WRITE_HANDLER( atarigen_6502_irq_ack_w );
  166.  
  167. void atarigen_ym2151_irq_gen(int irq);
  168.  
  169. WRITE_HANDLER( atarigen_sound_w );
  170. READ_HANDLER( atarigen_sound_r );
  171. WRITE_HANDLER( atarigen_sound_upper_w );
  172. READ_HANDLER( atarigen_sound_upper_r );
  173.  
  174. void atarigen_sound_reset(void);
  175. WRITE_HANDLER( atarigen_sound_reset_w );
  176. WRITE_HANDLER( atarigen_6502_sound_w );
  177. READ_HANDLER( atarigen_6502_sound_r );
  178.  
  179.  
  180.  
  181. /*--------------------------------------------------------------------------
  182.  
  183.     Misc sound helpers
  184.  
  185.         atarigen_init_6502_speedup - installs 6502 speedup cheat handler
  186.         atarigen_set_ym2151_vol - set the volume of the 2151 chip
  187.         atarigen_set_ym2413_vol - set the volume of the 2413 chip
  188.         atarigen_set_pokey_vol - set the volume of the POKEY chip(s)
  189.         atarigen_set_tms5220_vol - set the volume of the 5220 chip
  190.         atarigen_set_oki6295_vol - set the volume of the OKI6295
  191.  
  192. --------------------------------------------------------------------------*/
  193. void atarigen_init_6502_speedup(int cpunum, int compare_pc1, int compare_pc2);
  194. void atarigen_set_ym2151_vol(int volume);
  195. void atarigen_set_ym2413_vol(int volume);
  196. void atarigen_set_pokey_vol(int volume);
  197. void atarigen_set_tms5220_vol(int volume);
  198. void atarigen_set_oki6295_vol(int volume);
  199.  
  200.  
  201.  
  202. /***********************************************************************************************/
  203. /***********************************************************************************************/
  204. /***********************************************************************************************/
  205. /***********************************************************************************************/
  206. /***********************************************************************************************/
  207.  
  208.  
  209. /* general video globals */
  210. extern UINT8 *atarigen_playfieldram;
  211. extern UINT8 *atarigen_playfield2ram;
  212. extern UINT8 *atarigen_playfieldram_color;
  213. extern UINT8 *atarigen_playfield2ram_color;
  214. extern UINT8 *atarigen_spriteram;
  215. extern UINT8 *atarigen_alpharam;
  216. extern UINT8 *atarigen_vscroll;
  217. extern UINT8 *atarigen_hscroll;
  218.  
  219. extern size_t atarigen_playfieldram_size;
  220. extern size_t atarigen_playfield2ram_size;
  221. extern size_t atarigen_spriteram_size;
  222. extern size_t atarigen_alpharam_size;
  223.  
  224.  
  225. /*--------------------------------------------------------------------------
  226.  
  227.     Video scanline timing
  228.  
  229.         atarigen_scanline_callback - called every n scanlines
  230.  
  231.         atarigen_scanline_timer_reset - call to reset the system
  232.  
  233. --------------------------------------------------------------------------*/
  234. typedef void (*atarigen_scanline_callback)(int scanline);
  235.  
  236. void atarigen_scanline_timer_reset(atarigen_scanline_callback update_graphics, int frequency);
  237.  
  238.  
  239.  
  240. /*--------------------------------------------------------------------------
  241.  
  242.     Video Controller I/O: used in Shuuz, Thunderjaws, Relief Pitcher, Off the Wall
  243.  
  244.         atarigen_video_control_data - pointer to base of control memory
  245.         atarigen_video_control_state - current state of the video controller
  246.  
  247.         atarigen_video_control_reset - initializes the video controller
  248.  
  249.         atarigen_video_control_w - write handler for the video controller
  250.         atarigen_video_control_r - read handler for the video controller
  251.  
  252. --------------------------------------------------------------------------*/
  253. struct atarigen_video_control_state_desc
  254. {
  255.     int latch1;                                /* latch #1 value (-1 means disabled) */
  256.     int latch2;                                /* latch #2 value (-1 means disabled) */
  257.     int rowscroll_enable;                    /* true if row-scrolling is enabled */
  258.     int palette_bank;                        /* which palette bank is enabled */
  259.     int pf1_xscroll;                        /* playfield 1 xscroll */
  260.     int pf1_yscroll;                        /* playfield 1 yscroll */
  261.     int pf2_xscroll;                        /* playfield 2 xscroll */
  262.     int pf2_yscroll;                        /* playfield 2 yscroll */
  263.     int sprite_xscroll;                        /* sprite xscroll */
  264.     int sprite_yscroll;                        /* sprite xscroll */
  265. };
  266.  
  267. extern UINT8 *atarigen_video_control_data;
  268. extern struct atarigen_video_control_state_desc atarigen_video_control_state;
  269.  
  270. void atarigen_video_control_reset(void);
  271. void atarigen_video_control_update(const UINT8 *data);
  272.  
  273. WRITE_HANDLER( atarigen_video_control_w );
  274. READ_HANDLER( atarigen_video_control_r );
  275.  
  276.  
  277.  
  278. /*--------------------------------------------------------------------------
  279.  
  280.     Motion object rendering
  281.  
  282.         atarigen_mo_desc - description of the M.O. layout
  283.  
  284.         atarigen_mo_callback - called back for each M.O. during processing
  285.  
  286.         atarigen_mo_init - initializes and configures the M.O. list walker
  287.         atarigen_mo_free - frees all memory allocated by atarigen_mo_init
  288.         atarigen_mo_reset - reset for a new frame (use only if not using interrupt system)
  289.         atarigen_mo_update - updates the M.O. list for the given scanline
  290.         atarigen_mo_process - processes the current list
  291.  
  292. --------------------------------------------------------------------------*/
  293. #define ATARIGEN_MAX_MAXCOUNT                1024    /* no more than 1024 MO's ever */
  294.  
  295. struct atarigen_mo_desc
  296. {
  297.     int maxcount;                           /* maximum number of MO's */
  298.     int entryskip;                          /* number of bytes per MO entry */
  299.     int wordskip;                           /* number of bytes between MO words */
  300.     int ignoreword;                         /* ignore an entry if this word == 0xffff */
  301.     int linkword, linkshift, linkmask;        /* link = (data[linkword >> linkshift) & linkmask */
  302.     int reverse;                            /* render in reverse link order */
  303.     int entrywords;                            /* number of words/entry (0 defaults to 4) */
  304. };
  305.  
  306. typedef void (*atarigen_mo_callback)(const UINT16 *data, const struct rectangle *clip, void *param);
  307.  
  308. int atarigen_mo_init(const struct atarigen_mo_desc *source_desc);
  309. void atarigen_mo_free(void);
  310. void atarigen_mo_reset(void);
  311. void atarigen_mo_update(const UINT8 *base, int start, int scanline);
  312. void atarigen_mo_update_slip_512(const UINT8 *base, int scroll, int scanline, const UINT8 *slips);
  313. void atarigen_mo_process(atarigen_mo_callback callback, void *param);
  314.  
  315.  
  316.  
  317. /*--------------------------------------------------------------------------
  318.  
  319.     RLE Motion object rendering/decoding
  320.  
  321.         atarigen_rle_descriptor - describes a single object
  322.  
  323.         atarigen_rle_count - total number of objects found
  324.         atarigen_rle_info - array of descriptors for objects we found
  325.  
  326.         atarigen_rle_init - prescans the RLE objects
  327.         atarigen_rle_free - frees all memory allocated by atarigen_rle_init
  328.         atarigen_rle_render - render an RLE-compressed motion object
  329.  
  330. --------------------------------------------------------------------------*/
  331. struct atarigen_rle_descriptor
  332. {
  333.     int width;
  334.     int height;
  335.     INT16 xoffs;
  336.     INT16 yoffs;
  337.     int bpp;
  338.     UINT32 pen_usage;
  339.     UINT32 pen_usage_hi;
  340.     const UINT16 *table;
  341.     const UINT16 *data;
  342. };
  343.  
  344. extern int atarigen_rle_count;
  345. extern struct atarigen_rle_descriptor *atarigen_rle_info;
  346.  
  347. int atarigen_rle_init(int region, int colorbase);
  348. void atarigen_rle_free(void);
  349. void atarigen_rle_render(struct osd_bitmap *bitmap, struct atarigen_rle_descriptor *info, int color, int hflip, int vflip,
  350.     int x, int y, int xscale, int yscale, const struct rectangle *clip);
  351.  
  352.  
  353.  
  354. /*--------------------------------------------------------------------------
  355.  
  356.     Playfield rendering
  357.  
  358.         atarigen_pf_state - data block describing the playfield
  359.  
  360.         atarigen_pf_callback - called back for each chunk during processing
  361.  
  362.         atarigen_pf_init - initializes and configures the playfield params
  363.         atarigen_pf_free - frees all memory allocated by atarigen_pf_init
  364.         atarigen_pf_reset - reset for a new frame (use only if not using interrupt system)
  365.         atarigen_pf_update - updates the playfield params for the given scanline
  366.         atarigen_pf_process - processes the current list of parameters
  367.  
  368.         atarigen_pf2_init - same as above but for a second playfield
  369.         atarigen_pf2_free - same as above but for a second playfield
  370.         atarigen_pf2_reset - same as above but for a second playfield
  371.         atarigen_pf2_update - same as above but for a second playfield
  372.         atarigen_pf2_process - same as above but for a second playfield
  373.  
  374. --------------------------------------------------------------------------*/
  375. extern struct osd_bitmap *atarigen_pf_bitmap;
  376. extern UINT8 *atarigen_pf_dirty;
  377. extern UINT8 *atarigen_pf_visit;
  378.  
  379. extern struct osd_bitmap *atarigen_pf2_bitmap;
  380. extern UINT8 *atarigen_pf2_dirty;
  381. extern UINT8 *atarigen_pf2_visit;
  382.  
  383. extern struct osd_bitmap *atarigen_pf_overrender_bitmap;
  384. extern UINT16 atarigen_overrender_colortable[32];
  385.  
  386. struct atarigen_pf_desc
  387. {
  388.     int tilewidth, tileheight;              /* width/height of each tile */
  389.     int xtiles, ytiles;                        /* number of tiles in each direction */
  390.     int noscroll;                            /* non-scrolling? */
  391. };
  392.  
  393. struct atarigen_pf_state
  394. {
  395.     int hscroll;                            /* current horizontal starting offset */
  396.     int vscroll;                            /* current vertical starting offset */
  397.     int param[2];                            /* up to 2 other parameters that will cause a boundary break */
  398. };
  399.  
  400. typedef void (*atarigen_pf_callback)(const struct rectangle *tiles, const struct rectangle *clip, const struct atarigen_pf_state *state, void *param);
  401.  
  402. int atarigen_pf_init(const struct atarigen_pf_desc *source_desc);
  403. void atarigen_pf_free(void);
  404. void atarigen_pf_reset(void);
  405. void atarigen_pf_update(const struct atarigen_pf_state *state, int scanline);
  406. void atarigen_pf_process(atarigen_pf_callback callback, void *param, const struct rectangle *clip);
  407.  
  408. int atarigen_pf2_init(const struct atarigen_pf_desc *source_desc);
  409. void atarigen_pf2_free(void);
  410. void atarigen_pf2_reset(void);
  411. void atarigen_pf2_update(const struct atarigen_pf_state *state, int scanline);
  412. void atarigen_pf2_process(atarigen_pf_callback callback, void *param, const struct rectangle *clip);
  413.  
  414.  
  415.  
  416. /*--------------------------------------------------------------------------
  417.  
  418.     Misc Video stuff
  419.  
  420.         atarigen_get_hblank - returns the current HBLANK state
  421.         atarigen_halt_until_hblank_0_w - write handler for a HBLANK halt
  422.         atarigen_666_paletteram_w - 6-6-6 special RGB paletteram handler
  423.         atarigen_expanded_666_paletteram_w - byte version of above
  424.  
  425. --------------------------------------------------------------------------*/
  426. int atarigen_get_hblank(void);
  427. WRITE_HANDLER( atarigen_halt_until_hblank_0_w );
  428. WRITE_HANDLER( atarigen_666_paletteram_w );
  429. WRITE_HANDLER( atarigen_expanded_666_paletteram_w );
  430.  
  431.  
  432.  
  433. /*--------------------------------------------------------------------------
  434.  
  435.     General stuff
  436.  
  437.         atarigen_show_slapstic_message - display warning about slapstic
  438.         atarigen_show_sound_message - display warning about coins
  439.         atarigen_update_messages - update messages
  440.  
  441. --------------------------------------------------------------------------*/
  442. void atarigen_show_slapstic_message(void);
  443. void atarigen_show_sound_message(void);
  444. void atarigen_update_messages(void);
  445.  
  446.  
  447.  
  448. /*--------------------------------------------------------------------------
  449.  
  450.     Motion object drawing macros
  451.  
  452.         atarigen_mo_compute_clip - computes the M.O. clip rect
  453.         atarigen_mo_compute_clip_8x8 - computes the M.O. clip rect
  454.         atarigen_mo_compute_clip_16x16 - computes the M.O. clip rect
  455.  
  456.         atarigen_mo_draw - draws a generically-sized M.O.
  457.         atarigen_mo_draw_strip - draws a generically-sized M.O. strip
  458.         atarigen_mo_draw_8x8 - draws an 8x8 M.O.
  459.         atarigen_mo_draw_8x8_strip - draws an 8x8 M.O. strip (hsize == 1)
  460.         atarigen_mo_draw_16x16 - draws a 16x16 M.O.
  461.         atarigen_mo_draw_16x16_strip - draws a 16x16 M.O. strip (hsize == 1)
  462.  
  463. --------------------------------------------------------------------------*/
  464. #define atarigen_mo_compute_clip(dest, xpos, ypos, hsize, vsize, clip, tile_width, tile_height) \
  465. {                                                                                                \
  466.     /* determine the bounding box */                                                            \
  467.     dest.min_x = xpos;                                                                            \
  468.     dest.min_y = ypos;                                                                            \
  469.     dest.max_x = xpos + hsize * tile_width - 1;                                                    \
  470.     dest.max_y = ypos + vsize * tile_height - 1;                                                \
  471.                                                                                                 \
  472.     /* clip to the display */                                                                    \
  473.     if (dest.min_x < clip->min_x)                                                                \
  474.         dest.min_x = clip->min_x;                                                                \
  475.     else if (dest.min_x > clip->max_x)                                                            \
  476.         dest.min_x = clip->max_x;                                                                \
  477.     if (dest.max_x < clip->min_x)                                                                \
  478.         dest.max_x = clip->min_x;                                                                \
  479.     else if (dest.max_x > clip->max_x)                                                            \
  480.         dest.max_x = clip->max_x;                                                                \
  481.     if (dest.min_y < clip->min_y)                                                                \
  482.         dest.min_y = clip->min_y;                                                                \
  483.     else if (dest.min_y > clip->max_y)                                                            \
  484.         dest.min_y = clip->max_y;                                                                \
  485.     if (dest.max_y < clip->min_y)                                                                \
  486.         dest.max_y = clip->min_y;                                                                \
  487.     else if (dest.max_y > clip->max_y)                                                            \
  488.         dest.max_y = clip->max_y;                                                                \
  489. }
  490.  
  491. #define atarigen_mo_compute_clip_8x8(dest, xpos, ypos, hsize, vsize, clip) \
  492.     atarigen_mo_compute_clip(dest, xpos, ypos, hsize, vsize, clip, 8, 8)
  493.  
  494. #define atarigen_mo_compute_clip_16x8(dest, xpos, ypos, hsize, vsize, clip) \
  495.     atarigen_mo_compute_clip(dest, xpos, ypos, hsize, vsize, clip, 16, 8)
  496.  
  497. #define atarigen_mo_compute_clip_16x16(dest, xpos, ypos, hsize, vsize, clip) \
  498.     atarigen_mo_compute_clip(dest, xpos, ypos, hsize, vsize, clip, 16, 16)
  499.  
  500.  
  501. #define atarigen_mo_draw(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, tile_width, tile_height) \
  502. {                                                                                                        \
  503.     int tilex, tiley, screenx, screendx, screendy;                                                        \
  504.     int startx = x;                                                                                        \
  505.     int screeny = y;                                                                                    \
  506.     int tile = code;                                                                                    \
  507.                                                                                                         \
  508.     /* adjust for h flip */                                                                                \
  509.     if (hflip)                                                                                            \
  510.         startx += (hsize - 1) * tile_width, screendx = -tile_width;                                        \
  511.     else                                                                                                \
  512.         screendx = tile_width;                                                                            \
  513.                                                                                                         \
  514.     /* adjust for v flip */                                                                                \
  515.     if (vflip)                                                                                            \
  516.         screeny += (vsize - 1) * tile_height, screendy = -tile_height;                                    \
  517.     else                                                                                                \
  518.         screendy = tile_height;                                                                            \
  519.                                                                                                         \
  520.     /* loop over the height */                                                                            \
  521.     for (tiley = 0; tiley < vsize; tiley++, screeny += screendy)                                        \
  522.     {                                                                                                    \
  523.         /* clip the Y coordinate */                                                                        \
  524.         if (screeny <= clip->min_y - tile_height)                                                        \
  525.         {                                                                                                \
  526.             tile += hsize;                                                                                \
  527.             continue;                                                                                    \
  528.         }                                                                                                \
  529.         else if (screeny > clip->max_y)                                                                    \
  530.             break;                                                                                        \
  531.                                                                                                         \
  532.         /* loop over the width */                                                                        \
  533.         for (tilex = 0, screenx = startx; tilex < hsize; tilex++, screenx += screendx, tile++)            \
  534.         {                                                                                                \
  535.             /* clip the X coordinate */                                                                    \
  536.             if (screenx <= clip->min_x - tile_width || screenx > clip->max_x)                            \
  537.                 continue;                                                                                \
  538.                                                                                                         \
  539.             /* draw the sprite */                                                                        \
  540.             drawgfx(bitmap, gfx, tile, color, hflip, vflip, screenx, screeny, clip, trans, trans_pen);    \
  541.         }                                                                                                \
  542.     }                                                                                                    \
  543. }
  544.  
  545. #define atarigen_mo_draw_transparent(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, tile_width, tile_height) \
  546. {                                                                                                        \
  547.     UINT16 *temp = gfx->colortable;                                                                \
  548.     gfx->colortable = atarigen_overrender_colortable;                                                    \
  549.     atarigen_mo_draw(bitmap, gfx, code, 0, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, tile_width, tile_height);\
  550.     gfx->colortable = temp;                                                                                \
  551. }
  552.  
  553. #define atarigen_mo_draw_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen, tile_width, tile_height) \
  554. {                                                                                                        \
  555.     int tiley, screendy;                                                                                \
  556.     int screenx = x;                                                                                    \
  557.     int screeny = y;                                                                                    \
  558.     int tile = code;                                                                                    \
  559.                                                                                                         \
  560.     /* clip the X coordinate */                                                                            \
  561.     if (screenx > clip->min_x - tile_width && screenx <= clip->max_x)                                    \
  562.     {                                                                                                    \
  563.         /* adjust for v flip */                                                                            \
  564.         if (vflip)                                                                                        \
  565.             screeny += (vsize - 1) * tile_height, screendy = -tile_height;                                \
  566.         else                                                                                            \
  567.             screendy = tile_height;                                                                        \
  568.                                                                                                         \
  569.         /* loop over the height */                                                                        \
  570.         for (tiley = 0; tiley < vsize; tiley++, screeny += screendy, tile++)                            \
  571.         {                                                                                                \
  572.             /* clip the Y coordinate */                                                                    \
  573.             if (screeny <= clip->min_y - tile_height)                                                    \
  574.                 continue;                                                                                \
  575.             else if (screeny > clip->max_y)                                                                \
  576.                 break;                                                                                    \
  577.                                                                                                         \
  578.             /* draw the sprite */                                                                        \
  579.             drawgfx(bitmap, gfx, tile, color, hflip, vflip, screenx, screeny, clip, trans, trans_pen);    \
  580.         }                                                                                                \
  581.     }                                                                                                    \
  582. }
  583.  
  584. #define atarigen_mo_draw_transparent_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen, tile_width, tile_height) \
  585. {                                                                                                        \
  586.     UINT16 *temp = gfx->colortable;                                                                \
  587.     gfx->colortable = atarigen_overrender_colortable;                                                    \
  588.     atarigen_mo_draw_strip(bitmap, gfx, code, 0, hflip, vflip, x, y, vsize, clip, trans, trans_pen, tile_width, tile_height);\
  589.     gfx->colortable = temp;                                                                                \
  590. }
  591.  
  592.  
  593. #define atarigen_mo_draw_8x8(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  594.     atarigen_mo_draw(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 8, 8)
  595.  
  596. #define atarigen_mo_draw_16x8(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  597.     atarigen_mo_draw(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 16, 8)
  598.  
  599. #define atarigen_mo_draw_16x16(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  600.     atarigen_mo_draw(bitmap, gfx, code, color, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 16, 16)
  601.  
  602.  
  603. #define atarigen_mo_draw_transparent_8x8(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  604.     atarigen_mo_draw_transparent(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 8, 8)
  605.  
  606. #define atarigen_mo_draw_transparent_16x8(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  607.     atarigen_mo_draw_transparent(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 16, 8)
  608.  
  609. #define atarigen_mo_draw_transparent_16x16(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen) \
  610.     atarigen_mo_draw_transparent(bitmap, gfx, code, hflip, vflip, x, y, hsize, vsize, clip, trans, trans_pen, 16, 16)
  611.  
  612.  
  613. #define atarigen_mo_draw_8x8_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  614.     atarigen_mo_draw_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 8, 8)
  615.  
  616. #define atarigen_mo_draw_16x8_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  617.     atarigen_mo_draw_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 16, 8)
  618.  
  619. #define atarigen_mo_draw_16x16_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  620.     atarigen_mo_draw_strip(bitmap, gfx, code, color, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 16, 16)
  621.  
  622.  
  623. #define atarigen_mo_draw_transparent_8x8_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  624.     atarigen_mo_draw_transparent_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 8, 8)
  625.  
  626. #define atarigen_mo_draw_transparent_16x8_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  627.     atarigen_mo_draw_transparent_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 16, 8)
  628.  
  629. #define atarigen_mo_draw_transparent_16x16_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen) \
  630.     atarigen_mo_draw_transparent_strip(bitmap, gfx, code, hflip, vflip, x, y, vsize, clip, trans, trans_pen, 16, 16)
  631.  
  632. #endif
  633.